Alias File
A object of class Alias File is an alias--that is, a file that represents another file or volume. Icons for alias files have italicized names.PROPERTIES
An alias file has all the properties defined for object class File on page 60: Creator Type, File Type, Locked, Product Version, Stationery, and Version.Like any other file, an alias file also has all the properties defined for object class Item on page 72: Bounds, Comment, Container, Content Space, Creation Date, Disk, Folder, Icon, ID, Information Window, Kind, Label Index, Modification Date, Name, Physical Size, Position, Selected, Size, and Window.
Unlike other files, an alias file also has this property:
original item
- A reference to the original item associated with the alias file.
Class: Reference
Modifiable: NoELEMENT CLASSES
NoneCOMMANDS HANDLED
Clean Up, Copy, Count, Data Size, Delete, Duplicate, Eject, Empty, Exists, Get, Make, Move, Open, Print, Put Away, Reveal, Select, Sort, UpdateDEFAULT VALUE CLASS RETURNED
Reference to a file or, if you use the plural formalias files
, a list of references.EXAMPLE
If you run this script from the Script Editor, it reveals the original items for any alias files that are currently selected:
tell application "Finder" get selection repeat with moose in result if original item of moose exists then reveal original item of moose end if end repeat end tellThe Get statement in this script returns a list of references to the selected items. The Repeat statement tests the Original Item property for each selected alias file. If the property's value is a valid reference, the If statement asks the Finder to reveal the original item.For an example of a script application that performs a similar task, see the definition of the Reveal command on page 131. For examples of scripts that create alias files, see the definition of the Make command beginning on page 121.
NOTES
A reference to an object of class Alias File in a Tell statement addressed to the Finder is different from an AppleScript reference that uses an alias. You can use an AppleScript alias reference like this anywhere in a script to identify a file:
alias "Disk:Folder1:Folder2:...:Filename"When you compile the script (for example, by clicking the Check Syntax button in the Script Editor), AppleScript creates an alias record that identifies the file even after you move the file from its original location--as long as you don't recompile the script.Like an alias record, an alias file identifies another file or folder even after the original has been moved. However, a reference to an alias file is just like any other Finder reference: it must provide a complete description of the alias file's location in a form similar to this:
tell application "Finder" alias file "Filename" [ of container "ContainerX" ]... ¬ of container "Container1" [ of disk "Disk" ] end tellIf you move the alias file, the reference won't be accurate any longer. Also, if you attempt to use a Finder reference to an alias file outside of a Tell statement addressed to the Finder, the script won't run.